import java.util.Scanner;

public class P1980 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int num = 0, m;
        for (int i = 1; i <= n; i++) {
            m = i;
            while (m / 10 >= 1) {

                if (m % 10 == x) {
                    num++;
                }
                m = m / 10;
            }
            if (m == x) {
                num++;
            }
        }
        System.out.println(num);
    }
}